#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：pythonProject2 
@File    ：pdf_encrypted.py
@Author  ：beibei
@Date    ：2023/12/19 5:59 PM 
'''
import PyPDF2

def is_pdf_encrypted(file_path):
    try:
        with open(file_path, 'rb') as file:
            reader = PyPDF2.PdfReader(file)
            return reader.is_encrypted
    except Exception as e:
        print(f"Error occurred: {e}")
        return None


file_path = '/Users/peibei.lu/desktop/中国历史·秦汉魏晋南北朝卷.pdf'
encrypted = is_pdf_encrypted(file_path)
if encrypted is not None:
    print("Encrypted" if encrypted else "Not encrypted")



